package com.gs.mybatisflextest.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import com.gs.mybatisflextest.mapper.TbUserMapper;
import com.gs.mybatisflextest.model.TbUser;
import com.gs.mybatisflextest.service.TbUserService;
import com.gs.mybatisflextest.vo.UserVo;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.solon.service.impl.ServiceImpl;
import org.noear.solon.annotation.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component
public class TbUserServiceImpl extends ServiceImpl<TbUserMapper, TbUser> implements TbUserService {

    public static Logger log = LoggerFactory.getLogger(TbUserServiceImpl.class);

    @Override
    public UserVo queryUserVoUserId(String id) {
        QueryWrapper queryWrapper = QueryWrapper.create();
        queryWrapper
                .select()
                .eq(TbUser::getId,id);
        TimeInterval timer = DateUtil.timer();
        UserVo tmData = this.mapper.selectOneWithRelationsByQueryAs(queryWrapper, UserVo.class);
        log.info("查询用户信息耗时："+timer.interval()+"毫秒");
        return tmData;
    }
}
